package pack0703;

import jdk.swing.interop.SwingInterOpUtils;

import java.util.Calendar;
import java.util.Date;

public class CalendarDemo {
    public static void main(String[] args) {
        Date d=new Date();

        //获取当前的日历对象
        Calendar cal=Calendar.getInstance();

        //下面这两种意思一致
        System.out.println(d);
        System.out.println(cal);

        //获取日历中的某个部分
        System.out.println(cal.get(Calendar.YEAR)); //获取年
        System.out.println(cal.get(Calendar.MONTH)); //获取月
        System.out.println(cal.get(Calendar.DATE)); //获取日
        System.out.println(cal.get(Calendar.HOUR));
        System.out.println(cal.get(Calendar.MINUTE));
        System.out.println(cal.get(Calendar.SECOND));
        System.out.println(cal.get(Calendar.DAY_OF_MONTH));
        System.out.println(cal.get(Calendar.WEEK_OF_YEAR));

    }
}
